package com.itmyx.base.util.data;

import java.util.ArrayList;
import java.util.List;

import com.google.gson.Gson;


/**
 * 统一返回结果
 * new Result(0,data,null,null).toJson();
 * 默认 0为失败，1为成功
 * @author k
 *
 */
public class Result {
	
	private int returncode;
	private Object data;
	private String message;
	private String remark;
	
	//构造方法
	public Result(){}
	//有参构造方法
	public Result(int code,Object data,String message,String remark){
		setReturncode(code);
		setData(data == null?"":data);
		setMessage(message == null?"":message);
		setRemark(remark == null?"":remark);
	}
	//将Relust对象转换为json字符串
	public String toJson(){
		return new Gson().toJson(this);
	}
	//测试
	public static void main(String[] args) {
		List<String> data = new ArrayList<String>();
		data.add("问卷");
		data.add("问题");
		data.add("选项");
		Result r = new Result(0, data, "", "");
		System.out.println(r.toJson());
	}
	
	
	public int getReturncode() {
		return returncode;
	}
	public void setReturncode(int returncode) {
		this.returncode = returncode;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	
}
